package com.efast.dmom.mgmt.controller.mes;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.bean.mes.TwBatchDeleteBean;
import com.efast.dmom.mgmt.service.mes.TwBatchDeleteService;

@Controller
@RequestMapping("/delete")
public class TwBatchDeleteController {
	@Autowired
	private TwBatchDeleteService twBatchDeleteService;
	@RequestMapping(value="/deleteCheckItem", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteCheckItem(@RequestBody List<TwBatchDeleteBean>list)  {

		ResultBean result = new ResultBean(true,"'");
		twBatchDeleteService.deleteCheckItem(list);
		result.setMessage("删除成功！");
		return result;
	}
	@RequestMapping(value="/deleteDefectCode", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteDefectCode(@RequestBody List<TwBatchDeleteBean>list)  {

		ResultBean result = new ResultBean(true,"'");
		twBatchDeleteService.deleteDefectCode(list);
		result.setMessage("删除成功！");
		return result;
	}
	//批量删除检测项与缺陷代码
	@RequestMapping(value="/deleteCheckItemAndDefectCode", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteCheckItemAndDefectCode(@RequestBody List<TwBatchDeleteBean>list)  {

		ResultBean result = new ResultBean(true,"'");
		twBatchDeleteService.deleteCheckItemAndDefectCode(list);
		result.setMessage("删除成功！");
		return result;
	}
	
	// 新增时做重复性校验
	@RequestMapping(value="/addCheckItemAndDefectCode", method=RequestMethod.POST)
	public @ResponseBody ResultBean addCheckItemAndDefectCode(@RequestBody Map<String,Object> map) {
		ResultBean resultBean = new ResultBean(true);
		boolean addCheckItemAndDefectCode = twBatchDeleteService.addCheckItemAndDefectCode(map);
		if (!addCheckItemAndDefectCode) {
			resultBean.setSuccess(addCheckItemAndDefectCode);
		}
		return resultBean;
	}
	//删除工厂(逻辑校验)
	@RequestMapping(value="/deletePlant", method=RequestMethod.POST)
	public @ResponseBody ResultBean deletePlant(@RequestBody List<TwBatchDeleteBean>list)  {
		ResultBean resultBean = twBatchDeleteService.deletePlantInfo(list);
		return resultBean;
	}
	
	//删除车间(逻辑校验)
	@RequestMapping(value="/deleteShop", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteShop(@RequestBody List<TwBatchDeleteBean>list)  {
		ResultBean resultBean = twBatchDeleteService.deleteShopInfo(list);
		return resultBean;
	}
	//删除区域(逻辑校验)
	@RequestMapping(value="/deleteArea", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteArea(@RequestBody List<TwBatchDeleteBean>list)  {
		ResultBean resultBean = twBatchDeleteService.deleteAreaInfo(list);
		return resultBean;
	}
	//删除产线(逻辑校验)
	@RequestMapping(value="/deleteLine", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteLine(@RequestBody List<TwBatchDeleteBean>list)  {
		ResultBean resultBean = twBatchDeleteService.deleteLineInfo(list);
		return resultBean;
	}
	//删除工位(逻辑校验)
	@RequestMapping(value="/deleteStation", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteStation(@RequestBody List<TwBatchDeleteBean>list)  {
		ResultBean resultBean = twBatchDeleteService.deleteStationInfo(list);
		return resultBean;
	}
	//删除工序(逻辑校验)
	@RequestMapping(value="/deleteOperation", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteOperation(@RequestBody TwBatchDeleteBean enti)  {
		ResultBean resultBean = twBatchDeleteService.deleteOperationInfo(enti.getTmBasOperationId());
		return resultBean;
	}
}
